package com.myteam.fugaocrm.sqldb.mapper;

import java.util.Map;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.myteam.fugaocrm.modle.FgUser;

/**
 * 用户Mapper
 * @author BZX
 */
public interface FgUserMapper {
	/** 登录查询 */
	@Select("SELECT * FROM fg_user WHERE user_name = #{username} AND password = #{password} and is_delete = 0")
	public FgUser login(@Param("username") String username, @Param("password") String password);
	
	/** 根据用户名查询用户 */
	@Select("SELECT * FROM fg_user WHERE user_name = #{username} and is_delete = 0")
	public FgUser selectUserByUsername(@Param("username") String username);
	
	/** 根据用户名查询用户 */
	@Select("SELECT * FROM fg_user WHERE user_id = #{userId} and is_delete = 0")
	public FgUser selectUserByUserId(@Param("userId") Integer userId);

	/** 新增用户 */
	@Insert("INSERT into fg_user(user_name,password,created_date,modified_date) VALUES(#{username},#{password},#{createdDate},#{modifiedDate});")
	public void inster(Map<String, Object> params);
	
	/** 修改密码 */
	@Select("UPDATE fg_user SET password=#{password} WHERE user_id = #{userId} and is_delete = 0")
	public FgUser updatePassword(Map<String, Object> params);
}
